﻿#region File Info Header
/*________________________________________________________________________________________

  Copyright (C) 2011 Jason Zhang, eagleboost@msn.com

  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
  * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

________________________________________________________________________________________*/
#endregion File Info Header

namespace EagleBoost.Wpf.Infra.Extensions
{
  using System;

  /// <summary>
  /// Extension methods for Type
  /// </summary>
  public static class TypeExtension
  {
    /// <summary>
    /// Return true if the type is a number type
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public static bool IsNumber(this Type type)
    {
      switch (Type.GetTypeCode(type))
      {
        case TypeCode.Byte:
        case TypeCode.Int16:
        case TypeCode.UInt16:
        case TypeCode.Int32:
        case TypeCode.UInt32:
        case TypeCode.Int64:
        case TypeCode.UInt64:
        case TypeCode.Single:
        case TypeCode.Double:
        case TypeCode.Decimal:
          return true;
      }

      return false;
    }
  }
}
